package PTA;

import java.util.Scanner;

class Book {
    String name;
    int borrowDays;
    public Book(String name) {
        this.name = name;
    }
    public int calFines(int borrowDays) {
        return 0;
    }

    public String getName() {
        return name;
    }
}
class AdultBook extends Book {
    public AdultBook(String name) {
        super(name);
    }

    @Override
    public int calFines(int borrowDays) {
        int num = borrowDays - 21;
        if(num <= 0)
            return 0;
        if(num <= 3)
            return num * 2;
        else
            return (num - 3) * 5 + 3 * 2;
    }
}
class KidBook extends Book {
    public KidBook(String name) {
        super(name);
    }

    public int calFines(int borrowDays) {
        int num = borrowDays - 21;
        if(num <= 0)
            return 0;
        else
            return num;
    }
}
class Disc extends Book {
    public Disc(String name) {
        super(name);
    }

    public int calFines(int borrowDays) {
        int num = borrowDays - 14;
        if(num <= 0)
            return 0;
        if(num <= 3)
            return num * 5;
        else
            return (num - 3) * 10 + 3 * 5;
    }
}
class Customer {
    public double calTotalFines(Book books[], int borrowDays) {
        int sum = 0;
        for (int i = 0; i < books.length; i++) {
            sum += books[i].calFines(borrowDays);
        }
        return sum;
    }
}
public class t16 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scan=new Scanner(System.in);
        Book[] books=new Book[5];
        books[0]=new AdultBook("半小时漫画中国史");
        books[1]=new AdultBook("博弈论");
        books[2]=new KidBook("法布尔昆虫记");
        books[3]=new KidBook("最好的朋友");
        books[4]=new Disc("白雪公主");
        Customer customer=new Customer();
        int borrowDays=scan.nextInt();
        double fines=customer.calTotalFines(books, borrowDays);
        System.out.println("您共归还书籍"+books.length+"本");
        for(int i=0;i<books.length;i++)
            System.out.println((i+1)+" "+books[i].getName());
        System.out.println("借阅时间："+borrowDays+"天");
        if(fines>0)
            System.out.println("共需缴纳罚金："+fines+"元");
        else
            System.out.println("借阅书籍未超期");
        scan.close();
    }
}
